namespace Billing2
{
    using AjaxControlToolkit;
    using System;
    using System.Data;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class ucTemplate : UserControl
    {
        protected UpdatePanel ActionPanel;
        protected Button btnDelete;
        protected ConfirmButtonExtender btnDelete_ConfirmButtonExtender;
        protected Button btnSave;
        protected CheckBoxList CheckBoxList1;
        protected CheckBoxList CheckBoxList2;
        private DataTable dt;
        protected Panel PanelDetails;
        protected RadioButtonList RListIsActive;
        protected Timer TimerCloseIt;
        protected TextBox txtCCName;
        protected ucHighlight ucHighlight1;
        protected UpdatePanel updatePanel3;
        protected UpdateProgress UpdateProgress1;
        protected HiddenField xDialogID;
        protected HiddenField xPrimaryKey;

        public void BindDropDownListData()
        {
            DataTable dt1 = new ClsSitesInOrganization().SelectAll();
            for (int i = 0; i < dt1.Rows.Count; i++)
            {
            }
        }

        public void BindEditData()
        {
            if ((this.dt != null) && (this.dt.Rows.Count > 0))
            {
                this.xPrimaryKey.Value = Microsoft.Security.Application.Encoder.HtmlEncode(this.dt.Rows[0]["ID"].ToString());
                this.txtCCName.Text = this.dt.Rows[0]["CostCentreName"].ToString();
                this.RListIsActive.SelectedIndex = -1;
                this.RListIsActive.Items.FindByValue(this.dt.Rows[0]["CostCentreStatus"].ToString()).Selected = true;
            }
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ClsCostCentresInSite tblCC = new ClsCostCentresInSite();
            if (Convert.ToInt64(this.xPrimaryKey.Value) > 0)
            {
                tblCC.ID = Convert.ToInt64(this.xPrimaryKey.Value);
                tblCC.Delete();
                ClsUtilityHelper.ResetFormControlValues(this);
                this.TimerCloseIt.Enabled = true;
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            this.TimerCloseIt.Enabled = true;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.BindDropDownListData();
            }
            this.ucHighlight1.CloseAll();
            this.BindEditData();
        }

        protected void TimerCloseIt_Tick(object sender, EventArgs e)
        {
            ClsUtilityHelper.CloseJQueryDialog(this.DialogName, this);
            this.TimerCloseIt.Enabled = false;
            ClsUtilityHelper.EnableFormControlValues(this);
            this.ucHighlight1.CloseAll();
        }

        public bool Create0
        {
            get
            {
                return this.btnSave.Visible;
            }
            set
            {
                this.btnSave.Visible = value;
            }
        }

        public bool Delete0
        {
            get
            {
                return this.btnDelete.Visible;
            }
            set
            {
                this.btnDelete.Visible = value;
            }
        }

        public string DialogName
        {
            get
            {
                return this.xDialogID.Value;
            }
            set
            {
                this.xDialogID.Value = Microsoft.Security.Application.Encoder.HtmlEncode(value);
            }
        }

        public DataTable EditData
        {
            get
            {
                return this.dt;
            }
            set
            {
                this.dt = value;
                this.BindEditData();
                this.TimerCloseIt.Enabled = false;
            }
        }

        public bool Update0
        {
            get
            {
                return this.btnSave.Visible;
            }
            set
            {
                this.btnSave.Visible = value;
            }
        }
    }
}
